package com.guoyh.baseutils.utils

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Bundle
import com.guoyh.baseutils.R
import com.guoyh.baseutils.ext.currentActivity


/**
 * Activity工具类
 */
object ActStartUtils  {


    fun startActivity(aty: Context, clazz: Class<*>?,bundle: Bundle = Bundle()) {
        val i = Intent(aty, clazz)
        i.putExtras(bundle)
        if (aty is Activity){
            aty.startActivity(i)
            aty.overridePendingTransition(R.anim.zoomin, R.anim.zoomout)
        }else{
            currentActivity?.apply {
                startActivity(i)
                overridePendingTransition(R.anim.zoomin, R.anim.zoomout)
            }
        }
    }
    fun startActivityForResult(aty: Context, clazz: Class<*>?,bundle: Bundle = Bundle()) {
        val i = Intent(aty, clazz)
        i.putExtras(bundle)
        if (aty is Activity){
            aty.startActivityForResult(i,200)
            aty.overridePendingTransition(R.anim.zoomin, R.anim.zoomout)
        }else{
            currentActivity?.apply{
                startActivityForResult(i,200)
                overridePendingTransition(R.anim.zoomin, R.anim.zoomout)
            }
        }
    }


}